package main

import (
	"fmt"
	"net/http"
	"sync"
)

var wg sync.WaitGroup
var success, failed int

func work() {
	wg.Add(10000)
	for i := 0; i < 10000; i++ {
		go func() {
			defer wg.Done()
			resp, err := http.Get("http://192.168.133.2:8080/ping")
			if err == nil {
				resp.Body.Close()
				success += 1
			} else {
				failed += 1
			}
		}()
	}
	wg.Wait()
	fmt.Println("succes: ", success)
	fmt.Println("failed: ", failed)
	success = 0
	failed = 0
}

func main() {
	for i := 0; i < 10; i++ {
		work()
		fmt.Printf("work %d done\n", i)
	}
}
